package com.flex.mobile.timer;

import java.util.HashMap;

import com.flex.mobile.dao.model.TaxiTimer;

public class TimerHandlerSet implements TimerHandler{
	TimerHandler defaultHandler = null;
	HashMap<String, TimerHandler> hm = new HashMap<String, TimerHandler>();
	
	public synchronized  void setTimerHandler(TimerHandler th,String timerKind){
		hm.put(timerKind,th);
	}
	
	public void handlerTimer(TaxiTimer timer) {
		TimerHandler handler = (TimerHandler)hm.get(timer.getTimerKind());
		if (handler==null) handler = defaultHandler;
		
		if (handler != null){
			handler.handlerTimer(timer);
		}
	}

	public void setDefaultTimerHandler(TimerHandler timerHandler) {
		this.defaultHandler = timerHandler;
	}

}
